import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/Index/Home')
  },
]
const router = new VueRouter({
  routes
});

// 全局路由导航守卫
router.beforeEach((to, from, next) => {

  if (to.path == '/Pc_good') {
    // 判断存储是否有token值 判断是否登录
    if (sessionStorage.getItem('04A_token')) {
      // console.log(sessionStorage.getItem('04A_token'));
      next()
    } else {
      alert('请先登录')
    }
  } else if (to.path == '/Pc_collect') {
    // 判断存储是否有token值 判断是否登录
    if (sessionStorage.getItem('04A_token')) {
      // console.log(sessionStorage.getItem('04A_token'));
      next()
    } else {
      alert('请先登录')
    }
  } else {
    next()
  }
})

export default router;
